package net.elive.peer.share;

import java.util.HashMap;

import net.elive.bean.MediaDataBase;
import net.elive.tools.RandomNum;

/**
 * 资源管理 
 *    用户session 的资源管理
 * @author jincool.cao@gmail.com
 *
 */
public class SourceSessionIdManage {

	private HashMap<MediaDataBase,Integer> id;
	
	public SourceSessionIdManage(){
		id = new HashMap<MediaDataBase,Integer>();
	}
	
	public void changeAllSessionId(){
		id = new HashMap<MediaDataBase,Integer>();
	}
	
	public void changeSessionId(MediaDataBase mdb){
		id.put(mdb, RandomNum.randomInt());
	}
	
	public int getSessionId(MediaDataBase mdb){
		if(!id.containsKey(mdb)){
			id.put(mdb, RandomNum.randomInt());
		}
		return id.get(mdb);
	}
}
